<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>页面链接</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="icon" href="/favicon.ico" type="image/x-icon"/>
    <link media="all" type="text/css" rel="stylesheet" href="__STATIC__/editPage/css/bootstrap.min.css">
    <link media="all" type="text/css" rel="stylesheet" href="__STATIC__/editPage/css/layout.css">
   <script src="__STATIC__/editPage/js/jquery/jquery.min.js"></script>
    <script src="__STATIC__/editPage/js/bootstrap.min.js"></script>
    <script src="__STATIC__/js/app.js"></script>
    <style>body{ font-size: 14px;}</style>
</head>
<body style="overflow:visible;">
        <div class="panel-heading clearfix">
            选择自定义页面的链接
        </div>

<ul id="myTab" class="nav nav-tabs">
   <li class="active">
      <a href="#funhome" data-toggle="tab">
         功能链接
      </a>
   </li>
   <li><a href="#goods" data-toggle="tab" onclick="getLinkList('goods')">商品</a></li>
   <li><a href="#category" data-toggle="tab" >商品分类</a></li>
   <li><a href="#article" data-toggle="tab" onclick="getLinkList('article')">文章</a></li>

</ul>
<div id="myTabContent" class="tab-content">
        <div class="tab-pane fade in active" id="funhome">
            <div class="panel-body" style="max-height: 500px;">
                <table class="table table-striped table-condensed">
                    <thead>
                    <tr>
                        <th>标题</th>
                        <th>链接</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {volist name="links" id="vo"}
                        <tr>
                            <td>{$vo.name}</td>
                            <td>{$http_host}{$vo.url}</td>
                            <td>
                                <button class="btn btn-default" onclick="selectUrlCallback('{$vo.url}','{$searchType}','{$_menu_index}')">使用</button>
                            </td>
                        </tr>
                   {/volist}
                    </tbody>
                </table>
            </div>
   </div>

<!--商品-->
   <div class="tab-pane fade" id="goods">
      <form class="form-horizontal form-validate form-modal" method="post" id="search_form_goods" >
        <div class="row-fluid" style="margin-top:10px;">
            <select name="cid" style="width: 200px;margin-left:20px;padding:5px;" data-toggle="select2" data-placeholder="按分类筛选" data-chang="submit">
                      <option value="">所有分类</option>
                {volist name="classList" id="vo"}
                    <option value="{$vo.id}" >{$vo.icon|raw}{$vo.name}</option>
                {/volist}
            </select>&nbsp;&nbsp;商品名称：<input name="keyword" id="keyword" type="text" class="input-medium" placeholder="输入商品名称进行查找" value="" style="width: 200px;padding:5px;"/>
            <button type="button" onclick="getLinkList('goods')" style="width:60px;padding:5px;">查找</button>
        </div>
    </form>
       <div class="panel-body" style="max-height: 550px;">
           <table class="table table-striped table-condensed" >
            <thead>
                <tr>
                    <th>商品名称</th>
                    <th>商品链接</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody  id="data_list_goods">

                </tbody>
            </table>
           <div class="row-fluid" style="height:50px;margin:10px;padding-top:20px;border-top:1px solid #CCC;">
                共有 <span class="red" id="_count_num_goods">0</span> 条符合条件
                <button type="button"  id="p_page" onclick="getLinkList('goods','prev')">上一页</button>
                <span id="p_page_str">第<span id="_nowPage_goods">1</span>页/共<span id="_totalPages_goods">1</span>页</span>
                <button type="button" id="n_page" onclick="getLinkList('goods','next')">下一页</button>
          </div>
       </div>

   </div>
<!--商品-->
<!--商品分类-->
   <div class="tab-pane fade" id="category">
      <form class="form-horizontal form-validate form-modal" method="post" id="search_form_category" >
        <div class="row-fluid" style="margin-top:10px;">

        </div>
    </form>
       <div class="panel-body" style="max-height: 550px;">
           <table class="table table-striped table-condensed" >
            <thead>
                <tr>
                    <th>分类名称</th>
                    <th>分类链接</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody  >
                    {volist name="classList" id="vo"}
                         <tr>
                            <td>{$vo.icon|raw}{$vo.name}</td>
                            <td>{:_url('shop/goods/index',['cid'=>$vo['id']],false,true)}</td>
                            <td><button class="btn btn-default" onclick="selectUrlCallback('{:_url('shop/goods/index',['cid'=>$vo['id']],false,true)}','{$searchType}','{$_menu_index}')">使用</button></td>
                        </tr>
                    {/volist}
                </tbody>
            </table>
           <div class="row-fluid" style="height:50px;margin:10px;padding-top:20px;border-top:1px solid #CCC;">
                共有 <span class="red" id="_count_num_category">0</span> 条符合条件

          </div>
       </div>

   </div>
<!--商品分类-->
<!--文章-->
   <div class="tab-pane fade" id="article">
       <form class="form-horizontal form-validate form-modal" method="post" id="search_form_article" >
        <div class="row-fluid" style="margin-top:10px;">
            <select name="cid" style="width: 200px;margin-left:20px;padding:5px;" data-toggle="select2" data-placeholder="按文章标题筛选" data-chang="submit">
                      <option value="">所有分类</option>
					{$ArticleCatOpt|raw}
            </select>&nbsp;&nbsp;文章标题：<input name="keyword" id="keyword" type="text" class="input-medium" placeholder="输入文章标题进行查找" value="" style="width: 200px;padding:5px;"/>
            <button type="button" onclick="getLinkList('article')" style="width:60px;padding:5px;">查找</button>
        </div>
        </form>
       <div class="panel-body" style="max-height: 550px;">
        <table class="table table-striped table-condensed" >
                <thead>
                    <tr>
                        <th>文章标题</th>
                        <th>文章链接</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody  id="data_list_article">

                    </tbody>
            </table>
           <div class="row-fluid" style="height:50px;margin:10px;padding-top:20px;border-top:1px solid #CCC;">
                共有 <span class="red" id="_count_num_article">0</span> 条符合条件
                <button type="button"  id="p_page_article" onclick="getLinkList('article','prev')">上一页</button>
                <span id="p_page_str_article">第<span id="_nowPage_article">1</span>页/共<span id="_totalPages_article">1</span>页</span>
                <button type="button" id="articlen_page" onclick="getLinkList('article','next')">下一页</button>
          </div>
      </div>
   </div>
<!--文章-->

</div>
<script>
function selectUrlCallback(url,type,type_id){
        window.parent.McMore.selectUrlCallback(url,type,type_id);
}
function getLinkList(whatis,ptype){
	var arr = $('#search_form_'+whatis).toJson();
	arr.p = 1;
    if (ptype == 'prev'){
		if ($('#_nowPage_'+whatis).html() == 1) return false;
		arr.p = parseInt($('#_nowPage_'+whatis).html())-parseInt(1);
	}else if (ptype == 'next'){
		if ($('#_nowPage_'+whatis).html() == $('#_totalPages_'+whatis).html()) return false;
		arr.p = parseInt($('#_nowPage_'+whatis).html())+parseInt(1);
	}
	$('#data_list_'+whatis).html('');
    arr.runJson = 1;
    if(whatis == 'goods'){
        var res = jq_ajax('{:url("shop/sys_admin.goods/getList")}',arr);

    }else if(whatis == 'article'){
        var res = jq_ajax('{:url("mainadmin/article/getList")}',arr);
    }else{ return false;}

	if (res.info) alert(res.info);
	if (res.status == 0) return false;
	$('#_count_num_'+whatis).html(res.data.total_count);
	$('#_nowPage_'+whatis).html(res.data.page);
	$('#_totalPages_'+whatis).html(res.data.page_count);
    if(whatis == 'goods'){
        $.each(res.data.list,function(key,val){
            $('#data_list_'+whatis).append('<tr><td height=""><img style="display:block;" src="'+val.goods_thumb+'" width="100" height="100"/><p style="margin-top:10px;">'+val.goods_name+'</p></td><td height="100"><p style="margin-top:30px;">{:_url("shop/goods/info",["id"=>"【val.goods_id】"],'',true)}</p></td><td><button style="margin-top:50%;" class="btn btn-default" onclick="selectUrlCallback(\'{:_url("shop/goods/info",["id"=>"【val.goods_id】"],'',true)}\',\'{$searchType}\',\'{$_menu_index}\')">使用</button></td></tr>');
        })
    }else if(whatis == 'article'){
        $.each(res.data.list,function(key,val){
            $('#data_list_'+whatis).append('<tr><td >'+val.title+'</td><td >{:_url("shop/article/info",["id"=>"【val.id】"],'',true)}</td><td><button class="btn btn-default" onclick="selectUrlCallback(\'{:_url("shop/article/info",["id"=>"【val.id】"],'',true)}\',\'{$searchType}\',\'{$_menu_index}\')">使用</button></td></tr>');
        })
    }
}

</script>
</body>
</html>			